package cn.iocoder.yudao.module.member.controller.app.job;

import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.member.controller.admin.company.vo.CompanyPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.company.vo.CompanyRespVO;
import cn.iocoder.yudao.module.member.controller.admin.company.vo.CompanySaveReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.company.CompanyDO;
import cn.iocoder.yudao.module.member.service.company.CompanyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;

import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;


@Tag(name = "用户App - 企业")
@RestController
@RequestMapping("/member/company")
@Validated
public class AppCompanyController {

    @Resource
    private CompanyService companyService;


    @GetMapping("/get")
    @Operation(summary = "获得企业")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<CompanyRespVO> getCompany(@RequestParam("id") Long id) {
        CompanyDO company = companyService.getCompany(id);
        return success(BeanUtils.toBean(company, CompanyRespVO.class));
    }

    @GetMapping("/page")
    @Operation(summary = "获得企业分页")
    public CommonResult<PageResult<CompanyRespVO>> getCompanyPage(@Valid CompanyPageReqVO pageReqVO) {
        PageResult<CompanyRespVO> pageResult = companyService.getCompanyVoPage(pageReqVO);
        return success(pageResult);
    }

    @GetMapping("/list")
    @Operation(summary = "获得企业")
    public CommonResult<List<CompanyRespVO>> getCompanyList(@Valid CompanyPageReqVO pageReqVO) {
        List<CompanyDO> pageResult = companyService.getCompanyList(pageReqVO);
        return success(BeanUtils.toBean(pageResult, CompanyRespVO.class));
    }


}